package spring.boot.demo.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import spring.boot.demo.exception.MyException;

@Controller
public class HelloController {

	@ResponseBody
	@RequestMapping(value="/hello")
	public String hello() throws Exception{
		throw new Exception("发生错误");
	}
	
	@RequestMapping("/")
	public String index(ModelMap map){
		map.addAttribute("host","http://www.baidu.com");
		return "index";
	}
	
	@RequestMapping("/json")
    public String json() throws MyException {
        throw new MyException("发生错误2");
    }
}
